﻿class Error(Exception):
	"""Base class for exceptions"""
	def __init__(self, value):
		self.value = value
	def __str__(self):
		return repr(self.value)
	
class InitError(Error):
	"""Exception raised when the component requires
	initalization and this hasn't been done yet"""
	def __init__(self, value):
		self.value = "Must first be initialized"
		
class CrawlerLoadError(Error):
	"""Exception raised when a crawler can't be loaded"""
	def __init__(self, value):
		self.value = "Crawler can't be loaded: {name}".format(name=value)

class CrawlerInvalidError(Error):
	"""Exception raised when a crawler is loaded,
	but has no 'crawl' method and is thus invalid."""
	def __init__(self, value, reason):
		self.value = "Crawler {name} can't be loaded: {reason}".format(name=value, reason=reason)
		
class CrawlerNotLoadedError(Error):
	"""Exception raised when a crawler is tried
	to be removed but doesn't exist or isn't loaded"""
	def __init__(self, value):
		self.value = "Crawler {name} isn't loaded".format(name=value)